********************************************************************
* 
*  Code to replicate Tables 1-8 & Figure 1 :
*  Does Homeownership Reduce Wealth Disparities for
*  Low-Income and Minority Households
********************************************************************
**# START HERE! 
pwd
display as error "You need to define the working directory! To do so copy/paste the path to where these replication files are saved into the ""global root"" line in the replication_code.do file. "
pwd
global root 	"C:\???"	// <-- YOUR PATH THERE


**# Using Sample 
cd "$root"
import delimited "rep_sample_psuedo.csv", clear

	
**# Global Definitions

* @ Regressions
	global controls 		total_annl_incm_amnt	chldrn_mbr_cnt ///
							perinc perempl i.age_hh  
															
	global controls_NOincm 	chldrn_mbr_cnt	 perinc ///
							perempl i.age_hh 
	
	global awicomponents	total_annl_incm_amnt   toteqty_t	/// 	
							total_asst_cash_vlue 
	
	global hecomponents		mnthy_hmown_pymnt_amnt pmt ///
							origination mktvalue_0 loan_t mtgeqty_t ///
							mktvalue_t mktapprc_t toteqty_t

	global fe				hhid fyear 
	global clstr			cluster phaid 		 
	
	
* @ Summary Stats						
global housechar	vtenure_hvbfr  vtenure_hvdrng    hvdrng ///
					nonwhite age_hh  chldrn_mbr_cnt dsblty_indr  head_gnder   ///
					hshd_mbr_wage_cnt	 netchg_wagewrkn	hshd_mbr_wage_shr ///
					

global incexp		total_annl_incm_amnt   total_wage_incm_amnt  netchg_wageincm ///
					tnnt_rent_amnt	mnthy_hmown_pymnt_amnt

global wealth		total_asst_cash_vlue	toteqty_t  	wealth1 // wealth_pre

global neighbors	perinc  perempl ///
					sfd_prcnt  white_prcnt  propoo  pvrty_prcnt

global phas			pha_aviu_pct  pha_totnfam   pha_tothap_ml

global buytime		boom  bust  recovery

********************************************************************	 
capture program drop  regsetup
program define regsetup,
				
			qui estadd local HouseholdFE "\checkmark"
			qui estadd local yearFE "\checkmark"
			qui estadd local ageFE "\checkmark"
			qui estadd local clustered "\checkmark"	
	end
	
capture program drop  hascontrols
program define hascontrols,
				
			qui estadd local hascontrols "\checkmark"
	end	
	
	
	
********************************************************************
*
**#   Summary Tables
********************************************************************

format	%12.3f	$housechar  $incexp	$wealth	$neighbors	$phas	$buytime 								 										
global ssformat %12.3f %12.3f %12.3f %12.3f %12.3f 	%12.3f %12.3f %12.3f %12.3f %12.3f  ///	//(pre_wealth) %12.3f ///
				%12.0f %12.0f %12.0f %12.0f %12.0f 	%12.0f %12.0f %12.0f %12.0f %12.0f ///
				%12.3f %12.3f %12.3f %12.3f %12.3f 	%12.3f ///
				%12.0f	///
				%12.3f %12.3f %12.3f %12.3f
				
				
**# Summary Stats Table 1A : all & by renters/homeowners
local tablenum 	 Table1_AofC
local title "Household, Neighborhood, PHA Demographics"

	eststo clear

	eststo ss_all, title("Full Sample") : qui estpost tabstat  $housechar  $incexp	$wealth	$neighbors	$phas $buytime ,col(stat) stat(n mean p50 sd )

	eststo ss_rent, title("As Renters") : qui estpost tabstat  $housechar  $incexp	$wealth	$neighbors	$phas $buytime if  hvwindow<0 &  hvwindow!=., col(stat) stat(n mean p50 sd )

	eststo ss_own, title("As Homeowners") : qui estpost tabstat $housechar  $incexp	$wealth	$neighbors	$phas $buytime if hvwindow>=0  &  hvwindow!=., col(stat) stat(n mean p50 sd )
				
	eststo ttest_ss, title("diff"):  qui estpost ///
	ttest $housechar  total_annl_incm_amnt   total_wage_incm_amnt netchg_wageincm	 total_asst_cash_vlue  	wealth1	$neighbors	$phas  , by(hvdrng) 

	esttab  ,  compress noobs nonum 			 ///
		 refcat( vtenure_hvbfr "Households"   ///
		 total_annl_incm_amnt " Income & Expenses"  ///
		 total_asst_cash_vlue  " Wealth"  ///
		 perinc " Neighborhoods" 		///
		 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}"		///
		 boom " \vspace{0.025em}  \textbf{\emph{Purchase Timing}}", nolabel  )  ///
		cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt( $ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt( $ssformat) pat(0 0 0 1)) " ) 		star(* 0.1  ** 0.05  *** 0.01) ///
		 title(`title'  $th_1A) label  mlabels(,title span) 					 
		 
		 
	*** export to csv
	local tablenum 	 Table1_AofC
	local title "Household, Neighborhood, PHA Demographics"
	esttab ss_all ss_rent  ss_own ttest_ss  using "`tablenum'.csv", replace ///
			 refcat( vtenure_hvbfr "Households"   ///
			 total_annl_incm_amnt " Income & Expenses"  ///
			 total_asst_cash_vlue  " Wealth"  ///
			 perinc " Neighborhoods" 		///
			 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}"		///
			 boom " \vspace{0.025em}  \textbf{\emph{Purchase Timing}}", nolabel  )  ///
		  cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt( $ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt( $ssformat) pat(0 0 0 1)) " ) star(* 0.1  ** 0.05  *** 0.01) ///
		  gaps nolines compress label nonum nomtitle ///
		  mgroups( "Full Sample"  "As Renters" "As Homeowners" "\(diff_{mean}\)", pattern (1  1  1  1 ) ) ///
		  title(`title'  \label{`tablenum'}  \smallskip \\  $th_1A  ) 
		
		 
				
				 
**# Summary Stats Table 1B : renters  by race, in last LAST YEAR AS RENTERS	(Pre-treatment)

local tablenum 	 Table1_SSb
local title "Panel B: As Renters by Race, One Year Before Homeownership"

	eststo clear
														
	eststo rent, title("As Renters"): qui estpost tabstat    $housechar  $incexp	$wealth	$neighbors	$phas $buytime if  hvwindow== -1 			 , col(stat) stat( mean p50 sd n )
	eststo rentwht, title("As Renters, White")	: qui estpost tabstat    $housechar  $incexp	$wealth	$neighbors	$phas $buytime if  hvwindow== -1 & nonwhite==0, col(stat) stat( mean p50 sd n )
	eststo rentmin, title("As Renters, Minority"): qui estpost tabstat   $housechar  $incexp	$wealth	$neighbors	$phas $buytime if  hvwindow== -1 & nonwhite==1, col(stat) stat( mean p50 sd n)
		
		
		
		
	eststo ttest_rent, title("diff_White-Minority"):  qui estpost ///
	ttest $housechar total_annl_incm_amnt   total_wage_incm_amnt  netchg_wageincm	tnnt_rent_amnt total_asst_cash_vlue  wealth1   $neighbors  $phas  if  hvwindow== -1   , by(nonwhite) 
	
	display "$phas"
	 ///
		 	    
					 
					 
					 
					 
					esttab , compress noobs nonum 			 ///
						 refcat( vtenure_hvbfr "Households"   ///
						 total_annl_incm_amnt " Income & Expenses"  ///
						 total_asst_cash_vlue  " Wealth"  ///
						 perinc " Neighborhoods" 		///
						 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}"  , nolabel  )  ///
					cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt( $ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt( $ssformat) pat(0 0 0 1)) " ) 		star(* 0.1  ** 0.05  *** 0.01) ///
					 title(`title'  $th_1B ) label  mlabels(,title span) 							 

					 			 
		***# export to csv: 1B
		local tablenum 	 Table1_BofC
		local title "Panel B: As Renters by Race, One Year Before Homeownership"
		
		esttab rent* ttest_rent  using "`tablenum'.csv", replace ///
				 refcat( vtenure_hvbfr "Households"   ///
				 total_annl_incm_amnt " Income & Expenses"  ///
				 total_asst_cash_vlue  " Wealth"  ///
				 perinc " Neighborhoods" 		///
				 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}"			///  //boom " \vspace{0.025em}  \textbf{\emph{Purchase Timing}}" 
				 , nolabel  )  ///
		  cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt($ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt($ssformat) pat(0 0 0 1)) " ) 			star(* 0.1  ** 0.05  *** 0.01) ///
		  nogaps nolines compress /// //  ///
		  label nonum nomtitle mgroups( "All Renters"  "White Renters" "Minority Renters" "\(diff_{mean}\)", ///
		  pattern (1  1  1  1 ) ) ///
		  title(`title'  \label{`tablenum'}  \smallskip \\  $th_1B  )  ///
				

				
**# Summary Stats Table 1C : homeowners by race 
local tablenum 	 Table1_CofC
local title "Panel C: As Homeowners by Race"
	
	eststo clear
													
	eststo own, title("As Homeowners") : 		    qui estpost tabstat $housechar  $incexp	    $wealth	$neighbors	$phas $buytime if hvdrng==1, col(stat) stat(n mean p50 sd )
	eststo ownwht, title("As Homeowners, White") :   qui estpost tabstat $housechar  $incexp	$wealth	$neighbors	$phas $buytime if hvdrng==1 & nonwhite==0, col(stat) stat(n mean p50 sd )
	eststo ownmin, title("As Homeowners, Minority") : qui estpost tabstat $housechar  $incexp	$wealth	$neighbors	$phas $buytime if hvdrng==1 & nonwhite==1, col(stat) stat(n mean p50 sd )
	
	eststo ttest_own, title("diff_White-Minority"):  qui estpost ///
	ttest $housechar  total_annl_incm_amnt   total_wage_incm_amnt netchg_wageincm  mnthy_hmown_pymnt_amnt total_asst_cash_vlue toteqty_t wealth1   $neighbors  $phas   $buytime if hvdrng==1 , by(nonwhite)  
	
							 
				esttab , compress noobs nonum 			 ///
					 refcat( vtenure_hvbfr "Households"   ///
					 total_annl_incm_amnt " Income & Expenses"  ///
					 total_asst_cash_vlue  " Wealth"  ///
					 perinc " Neighborhoods" 		///
					 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}" ///  
					 boom " \vspace{0.025em}  \textbf{\emph{Purchase Timing}}", nolabel  )  ///
				cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt( $ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt( $ssformat) pat(0 0 0 1)) " ) 		star(* 0.1  ** 0.05  *** 0.01) ///
				 title(`title'  $th_1C) label  mlabels(,title span) 	
				
				
		
		***# export to csv: 1C
		local tablenum 	 Table1_CofC
		local title "Panel C: As Homeowners by Race"

		esttab own ownwht ownmin  ttest_own  using "`tablenum'.csv", replace ///
		   refcat( vtenure_hvbfr "Households"   ///
				 total_annl_incm_amnt " Income & Expenses"  ///
				 total_asst_cash_vlue  " Wealth"  ///
				 perinc " Neighborhoods" 		///
				 pha_aviu_pct	" \vspace{0.025em} \textbf{\emph{PHAs}}"			///
				 boom " \vspace{0.025em}  \textbf{\emph{Purchase Timing}}", nolabel  )  ///
		  cells("count(fmt(%12.0f) pat(1 1 1 0)) Mean( fmt($ssformat)  pat(1 1 1 0)) p50(fmt( $ssformat) pat(1 1 1 0))  SD(fmt($ssformat) pat(1 1 1 0)) b(star fmt($ssformat) pat(0 0 0 1)) " ) 	star(* 0.1  ** 0.05  *** 0.01) ///
		  nogaps nolines compress  ///
		  label nonum nomtitle mgroups( "All Homeowners" "White Homeowners" "Minority Homeowners" "diff_{mean}", ///
		  pattern (1  1  1  1 ) ) ///
		  title(`title'  \label{`tablenum'}  \smallskip \\  $th_1C  ) ///
	
	
********************************************************************************
*
**#   REGRESSION TABLES
*
********************************************************************************


**# Table 2: Reg 1: all households, Reg 2: only white , Reg 3: only-nonwhite, Reg 4: DiD 	
		
display as error "Wealth Accumulation for Low-Income \& Minority Households"	
	
	eststo clear
			
	qui eststo m1_wealth1:	reghdfe 	wealth1  i.hvdrng    $controls	   			, absorb($fe) vce($clstr)
		regsetup	
		hascontrols
		qui qui estadd ysumm , mean p50 sd 
			
	qui eststo m2_wealth1:	reghdfe 	wealth1  i.hvdrng	$controls if nonwhite==0, absorb($fe) vce($clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
		
	qui	eststo m3_wealth1:	reghdfe 	wealth1  i.hvdrng	 $controls if nonwhite==1, absorb($fe) vce($clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
		
	qui eststo m4_wealth1:	reghdfe 	wealth1  i.hvdrng##i.nonwhite  $controls,  absorb($fe) vce($clstr)
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd 
		
	
	esttab   , ///		
	order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label   nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars(  ymean yp50 ysd "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA" "N Obs.") 
		

	** export to csv	
	local tablenum 	Table2
	local title "Wealth Accumulation for Low-Income \& Minority Households"			
		
		esttab m1_*  m4_*   using "`tablenum'.csv", replace ///
		order( *hvdrng* *nonwhite* ) drop(*age_hh) ///
		label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
		scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") sfmt(0)  ///
		title(`title' \label{`tablenum'}  \\  $th_2  ) 
	
	

**# Table 3: W.A. Mechanisms/Channels (Internal): Fragility

display as error " Financial Fragility"		

	notes frgl q2_frgl highfrgl_hvstart
	codebook highfrgl_hvstart
	tabstat frgl, by(highfrgl_hvstart)
	
		
	local above_frgl 	highfrgl_hvstart==2 // high > median
	local below_frgl 	highfrgl_hvstart==1  // low < median
	
	eststo clear
	
	qui	eststo m1_wealth1, title("abvsp50_frgl"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if `above_frgl'  , absorb($fe) vce($clstr)
		regsetup	
		hascontrols		
		qui estadd ysumm , mean p50 sd 

	qui	eststo m2_wealth1, title("blwsp50_frgl"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if `below_frgl' , absorb($fe) vce($clstr) 
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd 


		esttab   ,  title ($th_3) ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") // booktabs

				
			
	**export to csv			
		local tablenum 	Table3	
		local title "Financial Fragility"
					
			esttab     using "`tablenum'.csv", replace ///
			order( *hvdrng* *nonwhite* ) drop(*age_hh) ///
			label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
			scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") sfmt(0)  ///
			title(`title' \label{`tablenum'}  \\ $th_3  ) 
			

	
**# Table 4:Labor Supply 	

display as error 	"@ W.A. Mechanisms/Channels (Internal):  Labor Supply"
		
eststo clear
	
display as error 	" Y= total_wage_incm_amnt;  dsblty_indr==0 "
	notes total_wage_incm_amnt
	qui eststo reg_ls1:	reghdfe  total_wage_incm_amnt i.hvdrng##i.nonwhite $controls_NOincm  if   dsblty_indr==0  , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
	
display as error	" Y=netchg_wageincm ;  dsblty_indr==0" 
	notes netchg_wageincm
	sum netchg_wageincm
	qui eststo reg_ls2:	reghdfe netchg_wageincm i.hvdrng##i.nonwhite $controls_NOincm  if   dsblty_indr==0 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd 
	
display as error	" Y=netchg_wagewrkn ;   dsblty_indr==0"
	notes  netchg_wagewrkn
	sum netchg_wagewrkn
	qui eststo reg_ls3:	reghdfe  netchg_wagewrkn i.hvdrng##i.nonwhite $controls_NOincm  if   dsblty_indr==0 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd		
		

		esttab   ,   ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01)  title($th_4) ///
		ar2 scalars(  "N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean (y)" "yp50 Med. (y)" "ysd  SD (y)") // booktabs



	** Table 4 export to csv	
		local tablenum 	Table4	
		local title "Labor market supply"
			esttab reg_ls1 reg_ls2 reg_ls3  using "`tablenum'.csv", replace ///
			order( *hvdrng* *nonwhite* ) drop(*age_hh) ///
			label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
			scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean (y)" "yp50 Med. (y)" "ysd  SD (y)") sfmt(0)  ///	
			mgroups( "Wage Income" "$\Delta$ Wage Income" "$\Delta$ Wage Earners", pattern (1 1 1) ) ///
			title(`title' \label{`tablenum'}  \\ $th_4 ) 

			

**# Table 5: Neighborhood Quality	
	 
display as error "**# Neighborhood Quality"
notes   *sfd_prcnt *white_prcnt  *propoo
codebook   sfd_prcnt white_prcnt propoo,compact

	eststo clear

	foreach measure in sfd_prcnt white_prcnt propoo pvrty_prcnt  {
				
	display as error " above median `measure'"	
	display as error " Y=wealth1"
			
	qui	eststo m1_`measure', title("abv_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if q2`measure'==2 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd 
		
	display as error "below median `measure'"	
	qui	eststo m2_`measure', title("blw_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite  $controls if	q2`measure'==1 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
	}
		
		esttab   , title ($th_5) ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label   nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") // booktabs


		** Table 5 export to csv	
		local tablenum 	Table5	
		local title  "Neighborhood Quality"

		esttab     using "`tablenum'.csv", replace ///
		order( *hvdrng* *nonwhite* )  drop(*age_hh) ///
		 longtable label noomit nobase nolines nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
		scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") sfmt(0)  ///
		mgroups(  "\shortstack{Med. SFD \% \\ Above vs. Below }" "\shortstack{Med. White Res. \% \\ Above vs. Below }" "\shortstack{Med. Owner Occpcy. \% \\ Above vs. Below }" "\shortstack{Med. Poverty \% \\ Above vs. Below }"   , pattern (1 0 1 0 1 0 1 0) ) ///
		title(`title' \label{`tablenum'}  \\ $th_5  ) 
	
	
	
**# Table 6: PHA Quality	

display as error " PHA Quality"

display as error "REMINDER!  We only have PHA Utilization rates for the following subsample years"
tab fyear if pha_totnfam!=.

	eststo clear

	foreach measure in pha_aviu_pct {
				
	display as error " above median `measure'"	
	qui	eststo above_pha, title("abv_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if q2`measure'==2, absorb($fe) vce( $clstr)
		regsetup	
		hascontrols
		qui estadd ysumm , mean p50 sd 

	display as error "below median `measure'"	
	qui	eststo below_pha, title("blw_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if	q2`measure'==1 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
		
		display as error " above median `measure' WITH PHA FE"		
		qui	eststo above_pha2, title("PHA_abv_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls i.phaid if q2`measure'==2, absorb($fe) vce( $clstr)
		regsetup
		hascontrols
		qui estadd ysumm , mean p50 sd 
		qui estadd local phaFE "\checkmark"

	display as error "below median `measure'  WITH PHA FE "	
	qui	eststo below_pha2, title("PHA_blw_`measure'"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls  i.phaid if	q2`measure'==1 , absorb($fe) vce( $clstr)
		regsetup	
		hascontrols	
		qui estadd ysumm , mean p50 sd 
		qui estadd local phaFE "\checkmark"

	}	
						
		esttab above_pha 	below_pha above_pha2 	below_pha2 , title($th_6) ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh ) depvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") 

		
		
	** Table 6 export to csv	
		local tablenum 	Table6	
		local title "PHA Quality"
			
			esttab  above_pha 	below_pha above_pha2 	below_pha2   using "`tablenum'.csv", replace ///
			order( *hvdrng* *nonwhite* )  drop(*age_hh )  ///
			label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
			scalars( "N Observations" "phaFE PHA FE" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth" ) sfmt(0)  ///
			mgroups(  "\shortstack[c]{PHA Voucher Utilization \%:\\ Above vs Below }"  "\shortstack[c]{w/PHA FE:\\ Above vs Below }" , pattern ( 1 0 1 0 ) ) ///
			title(`title' \label{`tablenum'} \\ $th_6 ) 

			

	
**# Table 7: Timing Test 

display as error " Timing Test "
notes boom bust recovery 
codebook  boom bust recovery ,compact
	
	eststo clear

	foreach measure in boom bust recovery  {				
	display as error "Timing: `measure'"	
				
		qui	eststo timing_`measure':	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if `measure'==1, absorb($fe) vce( $clstr)
			regsetup	
			hascontrols
			qui estadd ysumm , mean p50 sd 
			}
	
		esttab   , title($th_7)  ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars(  "N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") // booktabs

		** Table 7 export to csv	
		local tablenum 	Table7
		local title "Market Timing"
			esttab timing*    using "`tablenum'.csv", replace ///
			order( *hvdrng* *nonwhite* ) drop(*age_hh) ///
			label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
			scalars("N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") sfmt(0)  ///
			mgroups(    "\shortstack{Purchased in Boom  \\ 2001-2006}" "\shortstack{Purchased in Bust  \\ 2007-2012}" "\shortstack{Purchased in Recovery  \\ 2013-2020}", pattern ( 1 1 1 ) ) ///
			title(`title' \label{`tablenum'}  \\ $th_7  ) 
		
		



**# Table 8: Head of house type	

display as error  "**# Internal: head of house type"
codebook h6_cd ,compact
capture recode h6_cd (1 4=.) (3 6=0)  (2 5=1), gen(hhtype)
	
	label define htype 	0"No Disablity" 1 "Disablity",replace
	label var hhtype "HoH Type"
	label value hhtype htype
	tab hhtype
	
	eststo clear

	eststo m`i'_w1, title("No Dsblty"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if hhtype==0,  absorb($fe) vce( $clstr)
	regsetup	
	hascontrols
	qui estadd ysumm , mean p50 sd 
	
	eststo m`i'_w2, title("Dsblty"):	reghdfe wealth1 i.hvdrng##i.nonwhite $controls if hhtype==1,  absorb($fe) vce( $clstr)
	regsetup	
	hascontrols
	qui estadd ysumm , mean p50 sd 
		
		
		esttab   , title($th_8 ) ///		
		order( *hvdrng *nonwhite* ) drop(*age_hh) depvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) ///
		ar2 scalars( "N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") // booktabs

		
		
	**# Table 8 export to csv	
	
		local tablenum 	Table8	
		local title "Household Structure"
	esttab     using "`tablenum'.csv", replace ///
		order( *hvdrng* *nonwhite* ) drop(*age_hh) ///
		label noomit nobase  nogaps nomtitle ar2  t 	star(* 0.1  ** 0.05  *** 0.01) ///
		scalars(  "N Observations" "HouseholdFE Household FE" "yearFE Year FE" "ageFE HoH Age FE" "clustered Clustered PHA"  "ymean Mean Wealth" "yp50 Med. Wealth" "ysd  SD Wealth") sfmt(0)  ///	
		mgroups(  "No Disability" "Disability" , pattern ( 1 1) ) ///
		title(`title' \label{`tablenum'}  \\ $th_8    ) 
	
	
********************************************************************************
*
**#   FIGURE 1
*
********************************************************************************

global figxlabels      0.t*="-15" 1.t*="-14"  2.t*="-13" 3.t*="-12" 4.t*="-11" 5.t*="-10" 6.t*="-9" 7.t*="-8"  8.t*="-7" 9.t*="-6" 10.t*="-5"  11.t*="-4" 12.t*="-3" 13.t*="-2" 14.t*="-1" 15.t="0" 16.t*="1" 17.t*="2"  18.t*="3" 19.t*="4" 20.t*="5" 21.t*="6" 22.t*="7" 23.t*="8"  24.t*="9"  25.t*="10" 26.t*="11" 27.t*="12"  28.t*="13" 29.t*="14" 30.t*="15"  

global intfigxlabels    0.t#1.nonwhite="-15" 1.t#1.nonwhite="-14"  2.t#1.nonwhite="-13" 3.t#1.nonwhite="-12" 4.t#1.nonwhite="-11" 5.t#1.nonwhite="-10" 6.t#1.nonwhite="-9" 7.t#1.nonwhite="-8"  8.t#1.nonwhite="-7" 9.t#1.nonwhite="-6" 10.t#1.nonwhite="-5"  11.t#1.nonwhite="-4" 12.t#1.nonwhite="-3" 13.t#1.nonwhite="-2" 14.t#1.nonwhite="-1" 15.t#1.nonwhite="0" 16.t#1.nonwhite="1" 17.t#1.nonwhite="2"  18.t#1.nonwhite="3" 19.t#1.nonwhite="4" 20.t#1.nonwhite="5" 21.t#1.nonwhite="6" 22.t#1.nonwhite="7" 23.t#1.nonwhite="8"  24.t#1.nonwhite="9"  25.t#1.nonwhite="10" 26.t#1.nonwhite="11" 27.t#1.nonwhite="12"  28.t#1.nonwhite="13" 29.t#1.nonwhite="14" 30.t#1.nonwhite="15" 0.t#0.nonwhite="-15" 

preserve
keep if    t> 11  & t<21

	eststo clear	
	eststo v1:	reghdfe 	wealth1  $controls ib15.t##i.nonwhite  i.tpre15##i.nonwhite i.tpost15##i.nonwhite   , absorb($fe) vce($clstr)
	eststo v2:	reghdfe 	wealth1   $controls ib15.t##i.nonwhite  i.tpre15##i.nonwhite i.tpost15##i.nonwhite   , absorb($fe) vce($clstr)
	
	
	display as error "Y= Weath; Homeownership Transition Year = HV Start Year"		
	esttab  , order( *nonwhite* ) drop(*age_hh)  omit nodepvar label  noomit nobase  nogaps  lines mtitle cell("b(fmt( %15.2fc) star)" t(par fmt( %15.2fc))) star(* 0.1  ** 0.05  *** 0.01) 	ar2 
	

		coefplot (v1, label(White Households) mcolor(green) keep(*.t)) (v2, label( Diff-in-Minority Households)  mcolor(blue) keep(*.t#1.nonwhite))  ,	 vertical base xlabel(,angle(90)) ///
		rename($intfigxlabels $figxlabels )  ///
		title ("Differences in Household Wealth")  ///
		subtitle("Coef. on Homeownership-Tenure(t) & Minority interaction")  ///
		xtitle("Household Years, Relative to Start of Homeownership (t=0)")  ///
		drop(_cons) xline(4) omitted  ///
		graphregion(fcolor(white))   ///
		 ylabel(,angle(90) )   
		
restore	 
		
			